﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Message.xaml.cs" company="arvystate.net">
//   arvystate.net
// </copyright>
// <summary>
//   Interaction logic for Message.xaml
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace PresentationAid.Dialog
{
    using System;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media.Imaging;

    using NLog;

    /// <summary>
    /// Interaction logic for Message
    /// </summary>
    public sealed partial class Message
    {
        #region Static Fields

        /// <summary>
        /// The logger.
        /// </summary>
        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Message"/> class.
        /// </summary>
        public Message()
        {
            Logger.Trace("Init: Message");

            this.InitializeComponent();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the dialog result.
        /// </summary>
        public new MessageBoxResult DialogResult { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The set icon.
        /// </summary>
        /// <param name="iconUrl">
        /// The icon url.
        /// </param>
        public void SetIcon(string iconUrl)
        {
            if (!string.IsNullOrEmpty(iconUrl))
            {
                this.MessageBoxIcon.Source =
                    new BitmapImage(
                        new Uri(
                            "/PresentationAid;component/Resources/Images/Icons/" + iconUrl + "_32.png", 
                            UriKind.RelativeOrAbsolute));
            }
            else
            {
                this.MessageBoxIcon.Visibility = Visibility.Collapsed;
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// The button 1 click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void Button1Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = MessageBoxResult.Yes;
            this.Close();
        }

        /// <summary>
        /// The button 2 click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void Button2Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = MessageBoxResult.No;
            this.Close();
        }

        /// <summary>
        /// The button 3 click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void Button3Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = MessageBoxResult.Cancel;
            this.Close();
        }

        /// <summary>
        /// The window key up.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void WindowKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }

            this.DialogResult = MessageBoxResult.None;
            this.Close();
        }

        #endregion
    }
}